import request from '@/utils/request'
import {param} from 'jquery'

//获取云机仓库
export function warehouseList(query) {
  return request({
    url: '/machine/warehouse/list',
    method: 'get',
    params: query
  })
}


// 获取云机列表
export function tenantLists(query) {
  return request({
    url: '/machine/tenant/list',
    method: 'get',
    params: query
  })
}


// 租用云机
export function rentCloudMachine(data) {
  return request({
    url: '/machine/tenant/rent',
    method: 'post',
    data: data
  })
}

// 续费云机
export function renewCloudMachine(data) {
  return request({
    url: '/machine/tenant/renew',
    method: 'post',
    data: data
  })
}

// 获取云机详情
export function getCloudMachineDetail(id) {
  return request({
    url: `/machine/tenant/${id}`,
    method: 'get'
  })
}

// 删除云机
export function deleteCloudMachine(id) {
  return request({
    url: `/machine/tenant/${id}`,
    method: 'delete'
  })
}


//添加挂q
export function addQ(params) {
  return request({
    url: `/machine/account/create`,
    method: 'post',
    data: params
  })
}


//  查询云机账号列表

export function getQDetail(params) {
  return request({
    url: `/machine/account/list`,
    method: 'get',
    params: params
  })
}

// 打开QQ账号
export function openAccount(data) {
  return request({
    url: '/machine/account/open',
    method: 'post',
    data: data

  })
}

// 关闭QQ账号
export function closeAccount(data) {
  return request({
    url: '/machine/account/close',
    method: 'post',
    data: data
  })
}

// 删除QQ账号
export function deleteAccount(data) {
  return request({
    url: '/machine/account/delete',
    method: 'delete',
    data: data
  })
}

// 批量打开QQ账号
export function batchOpenAccount(data) {
  return request({
    url: '/machine/account/batch/open',
    method: 'post',
    data: data
  })
}

// 批量关闭QQ账号
export function batchCloseAccount(data) {
  return request({
    url: '/machine/account/batch/close',
    method: 'post',
    data: data
  })
}

// 批量删除QQ账号
export function batchDeleteAccount(data) {
  return request({
    url: '/machine/account/batch/delete',
    method: 'delete',
    data: data
  })
}


//获取视频流
export function getwsVideo() {
  return request({
    url: '/machine/tenant/get/video',
    method: 'get',

  })
}


//同步云机仓库
export function sync() {
  return request({
    url: '/machine/warehouse/sync',
    method: 'get',

  })
}

//确认登录
export function yunjilogin(sessionId, dataType,id,onlineStatus) {
  return request({
    url: '/machine/account/login',
    method: 'post',
    data: {sessionId: sessionId, dataType: dataType,id:id,onlineStatus:onlineStatus}
  })
}

//关闭账号
export function yunjiClose(id) {
  return request({
    url: '/machine/account/close',
    method: 'post',
    data:{id}
  })
}

//关闭连接
export function linkClose(accountId) {
  return request({
    url: '/machine/warehouse/link/close',
    method: 'get',
    params: {accountId}
  })
}

// 强制到期商家云机
export function makeMachineExpire(machineId) {
  return request({
    url: '/machine/warehouse/make/expire',
    method: 'post',
    data: {machineId}
  })
}

//删除账号

export function delAccount(data) {
  return request({
    url: '/machine/account/delete',
    method: 'post',
    data: data
  })
}

//删除所有账号

export function delAllAccount(machineId) {
  return request({
    url: '/machine/tenant/del/allAccount',
    method: 'get',
    params: {machineId: machineId}
  })
}


//刷新状态

export function seeStatus(data) {
  return request({
    url: '/machine/account/show',
    method: 'post',
    data: data
  })
}

//修改商家云机
export function editTenant(data) {
  return request({
    url: '/machine/tenant',
    method: 'put',
    data: data
  })
}


//查看状态

export function checkYunji(machineId) {
  return request({
    url: '/machine/warehouse/link/check',
    method: 'get',
    params: {machineId: machineId}
  })
}


//扫码上号
export function scanCode(data) {
  return request({
    url: '/machine/account/scan',
    method: 'post',
    data: data
  })
}

//查询所有的账号列表
export function getAllList(data) {
  return request({
    url: '/machine/tenant/account/all',
    method: 'get',
    params: data
  })
}

//自动扫码
export function scanAuto(data) {
  return request({
    url: '/machine/account/scan/auto',
    method: 'post',
    data: data,
    timeout: 40000
  })
}
//修改云机启用或类型
export function update(data) {
  return request({
    url: '/machine/warehouse/update',
    method: 'post',
    data: data
  })
}

//操作记录表

export function operateList(data) {
  return request({
    url: '/machine/tenant/operate/list',
    method: 'get',
    params:data
  })
}

//自动续费
export function renewal(data) {
  return request({
    url: '/machine/tenant/setting/renewal',
    method: 'post',
    data:data
  })
}

// 云机仓库, 关闭远程
export function adminClose(id) {
  return request({
    url: '/machine/warehouse/admin/close',
    method: 'get',
    params:{id:id}
  })
}


//获取视频流
export function yunjiVideo(machineId) {
  return request({
    url: '/machine/tenant/get/video',
    method: 'get',
    params:{machineId:machineId}
  })
}

// 账号列表 修改备注
export function yunjiRemark(data) {
  return request({
    url: '/machine/account/update/remark',
    method:'post',
    data:data
  })
}

//添加商家分组
export function addGroup(data) {
  return request({
    url: '/machine/warehouse/create/group',
    method:'post',
    data:data
  })
}
//查询商家分组列表
export function groupList(data) {
  return request({
    url: '/machine/warehouse/list/group',
    method:'get',
    params:data
  })
}
//修改商家分组
export function updateGroup(data) {
  return request({
    url: '/machine/warehouse/update/group',
    method:'post',
    data:data
  })
}
